<template>
  <div class="mod-config">
    <basic-container>

      <el-form :inline="true"  v-show="searchShow" ref="searchForm"  :model="dataForm" @keyup.enter.native="searchChange()">
        <el-form-item label="代码" prop="code">
          <el-input v-model="dataForm.code" placeholder="代码" size="mini"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="searchChange">查询</el-button>
          <el-button type="default" icon="el-icon-delete" size="mini" @click="searchReset">清空</el-button>
        </el-form-item>

      </el-form>
      <el-row>
      <el-col :span="24">
        <el-button v-if="permissions.mp_wxdataconfiguration_add" icon="el-icon-plus" type="primary" size="mini" @click="addOrUpdateHandle()">新增</el-button>
        <el-button icon="el-icon-search" circle size="mini" @click="handleSearchShow" style="float:right;"></el-button>
        <el-button icon="el-icon-refresh" circle size="mini" @click="refreshChange" style="float:right;"></el-button>
        <!-- <el-button icon="el-icon-menu" circle size="mini" style="float:right;"></el-button>-->

      </el-col>
      </el-row>
      <div class="avue-crud">
        <el-table
                :data="dataList"
                border
                v-loading="dataListLoading">
                      <el-table-column
                    prop="id"
                    header-align="center"
                    align="center"
                    label="id">
            </el-table-column>
                      <el-table-column
                    prop="storeList"
                    header-align="center"
                    align="center"
                    label="门店列表图文中的第一张默认大图(建议尺寸(640*320))">
            </el-table-column>
                      <el-table-column
                    prop="articleList"
                    header-align="center"
                    align="center"
                    label="文章列表图文中的第一张默认大图(建议尺寸(640*320))">
            </el-table-column>
                      <el-table-column
                    prop="articleListTwo"
                    header-align="center"
                    align="center"
                    label="文章列表图文中的非一张默认小图(建议尺寸(80*80))">
            </el-table-column>
                      <el-table-column
                    prop="enterpriseLogo"
                    header-align="center"
                    align="center"
                    label="个人中心中的企业Logo(建议尺寸(640*320))">
            </el-table-column>
                      <el-table-column
                    prop="customerData"
                    header-align="center"
                    align="center"
                    label="会员资料中的默认图(建议尺寸(640*320))">
            </el-table-column>
                      <el-table-column
                    prop="registerAgreement"
                    header-align="center"
                    align="center"
                    label="注册协议对应文章内容">
            </el-table-column>
                      <el-table-column
                    prop="integralChange"
                    header-align="center"
                    align="center"
                    label="积分兑换协议对应文章内容">
            </el-table-column>
                      <el-table-column
                    prop="appointmentDescription"
                    header-align="center"
                    align="center"
                    label="预约说明对应对应文章内容">
            </el-table-column>
                      <el-table-column
                    prop="latestTechnologySharing"
                    header-align="center"
                    align="center"
                    label="最新技术分享">
            </el-table-column>
                      <el-table-column
                    prop="contactWay"
                    header-align="center"
                    align="center"
                    label="联系我们中的联系方式对应文章内容">
            </el-table-column>
                      <el-table-column
                    prop="storeRoute"
                    header-align="center"
                    align="center"
                    label="联系我们中的来店路线对应文章内容">
            </el-table-column>
                      <el-table-column
                    prop="latestActivity"
                    header-align="center"
                    align="center"
                    label="最新活动">
            </el-table-column>
                      <el-table-column
                    prop="inviteFriend"
                    header-align="center"
                    align="center"
                    label="邀请好友中的说明对应文章内容">
            </el-table-column>
                      <el-table-column
                    prop="inviteFriendShare"
                    header-align="center"
                    align="center"
                    label="邀请好友成功分享页面中的说明对应文章内容">
            </el-table-column>
                      <el-table-column
                    prop="memberDifferent"
                    header-align="center"
                    align="center"
                    label="蓝星、红星会员区别说明对应文章内容">
            </el-table-column>
                      <el-table-column
                    prop="wxAppointmentDescription"
                    header-align="center"
                    align="center"
                    label="微信预约说明对应文章内容">
            </el-table-column>
                      <el-table-column
                    prop="inviteFriendPrivacy"
                    header-align="center"
                    align="center"
                    label="邀请好友隐私权政策说明对应文章内容">
            </el-table-column>
                      <el-table-column
                    prop="registerSuccessInfo"
                    header-align="center"
                    align="center"
                    label="会员注册成功页面弹出信息">
            </el-table-column>
                      <el-table-column
                    prop="inviteFriendSuccessInfo"
                    header-align="center"
                    align="center"
                    label="邀请好友成功页面弹出信息">
            </el-table-column>
                      <el-table-column
                    prop="inviteFriendFailInfo"
                    header-align="center"
                    align="center"
                    label="邀请好友失败页面弹出信息">
            </el-table-column>
                      <el-table-column
                    prop="integralChangeSuccessInfo"
                    header-align="center"
                    align="center"
                    label="积分商城兑换成功弹出信息">
            </el-table-column>
                      <el-table-column
                    prop="integralChangeAffirmInfo"
                    header-align="center"
                    align="center"
                    label="积分商城兑换确认弹出信息">
            </el-table-column>
                      <el-table-column
                    prop="wxAppointmentSuccessInfo"
                    header-align="center"
                    align="center"
                    label="微信预约成功页面弹出信息">
            </el-table-column>
                      <el-table-column
                    prop="wxAppointmentFailInfo"
                    header-align="center"
                    align="center"
                    label="微信预约失败页面弹出信息">
            </el-table-column>
                      <el-table-column
                    prop="wechatBindingInfo"
                    header-align="center"
                    align="center"
                    label="微信绑定填写详细信息时备注内容">
            </el-table-column>
                      <el-table-column
                    prop="wechatUnbound"
                    header-align="center"
                    align="center"
                    label="微信未绑定时点击菜单弹出内容">
            </el-table-column>
                      <el-table-column
                    prop="integralShow"
                    header-align="center"
                    align="center"
                    label="【积分】在系统中显示为">
            </el-table-column>
                      <el-table-column
                    prop="saveMoneyCardShow"
                    header-align="center"
                    align="center"
                    label="【储值卡】在系统中显示为">
            </el-table-column>
                      <el-table-column
                    prop="doctorAdviceShow"
                    header-align="center"
                    align="center"
                    label="【消息中心】的最新医嘱在系统中显示为">
            </el-table-column>
                      <el-table-column
                    prop="diagnosisInfoShow"
                    header-align="center"
                    align="center"
                    label="【消息中心】的最新诊疗信息在系统中显示为	">
            </el-table-column>
                      <el-table-column
                    prop="myCaseShow"
                    header-align="center"
                    align="center"
                    label="个人中心主页面【我的病例】在系统中显示为">
            </el-table-column>
                      <el-table-column
                    prop="registerPayShow"
                    header-align="center"
                    align="center"
                    label="个人中心中的【挂号支付】功能的显示名称">
            </el-table-column>
                      <el-table-column
                    prop="myDataShow"
                    header-align="center"
                    align="center"
                    label="个人中心中的【我的资料】功能的显示名称">
            </el-table-column>
                      <el-table-column
                    prop="messageCenterShow"
                    header-align="center"
                    align="center"
                    label="个人中心中的【消息中心】功能的显示名称	">
            </el-table-column>
                      <el-table-column
                    prop="prescribeSpectaclesPayShow"
                    header-align="center"
                    align="center"
                    label="个人中心中的【配镜支付】功能的显示名称">
            </el-table-column>
                      <el-table-column
                    prop="myVoucherShow"
                    header-align="center"
                    align="center"
                    label="个人中心中的【我的代金券】功能的显示名称">
            </el-table-column>
                      <el-table-column
                    prop="inviteFriendShow"
                    header-align="center"
                    align="center"
                    label="个人中心中的【邀请好友】功能的显示名称">
            </el-table-column>
                      <el-table-column
                    prop="appointmentRegisterShow"
                    header-align="center"
                    align="center"
                    label="个人中心中的【预约挂号】功能的显示名称">
            </el-table-column>
                      <el-table-column
                    prop="myIntegralShow"
                    header-align="center"
                    align="center"
                    label="个人中心中的【我的积分】功能的显示名称">
            </el-table-column>
                      <el-table-column
                    prop="customerServiceShow"
                    header-align="center"
                    align="center"
                    label="个人中心中的【客户服务】功能的显示名称">
            </el-table-column>
                      <el-table-column
                    prop="dedicatedCustomerServiceShow"
                    header-align="center"
                    align="center"
                    label="个人中心中的【专属客服】功能的显示名称">
            </el-table-column>
                    <el-table-column
                  header-align="center"
                  align="center"
                  label="操作">
            <template slot-scope="scope">
              <el-button v-if="permissions.mp_wxdataconfiguration_edit" type="text" size="small" icon="el-icon-edit" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
              <el-button v-if="permissions.mp_wxdataconfiguration_del" type="text" size="small" icon="el-icon-delete" @click="deleteHandle(scope.row.id)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>

      <div class="avue-crud__pagination">
        <el-pagination
                @size-change="sizeChangeHandle"
                @current-change="currentChangeHandle"
                :current-page="pageIndex"
                :page-sizes="[10, 20, 50, 100]"
                :page-size="pageSize"
                :total="totalPage"
                background
                layout="total, sizes, prev, pager, next, jumper">
        </el-pagination>
      </div>
      <!-- 弹窗, 新增 / 修改 -->
      <table-form v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></table-form>
    </basic-container>
  </div>
</template>

<script>
  import {fetchWxDataConfigurationList, delWxDataConfigurationObj} from '@/api/mp/wxdataconfiguration'
  import TableForm from './wxdataconfiguration-form'
  import {mapGetters} from 'vuex'
  export default {
    data () {
      return {
        dataForm: {
          key: ''
        },
        dataList: [],
        searchShow:true,
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        addOrUpdateVisible: false
      }
    },
    components: {
      TableForm
    },
    created () {
      this.getDataList()
    },
    computed: {
      ...mapGetters(['permissions'])
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        fetchWxDataConfigurationList(Object.assign({
          current: this.pageIndex,
          size: this.pageSize
        })).then(response => {
          this.dataList = response.data.data.records
          this.totalPage = response.data.data.total
        })
        this.dataListLoading = false
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 新增 / 修改
      addOrUpdateHandle (id) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(id)
        })
      },
      // 删除
      deleteHandle (id) {
        this.$confirm('是否确认删除ID为' + id, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(function () {
          return delWxDataConfigurationObj(id)
        }).then(data => {
          this.$message.success('删除成功')
          this.getDataList()
        })
      },
      searchChange() {
        this.pageIndex=1;
        this.getDataList()
      },
      // 搜索清空
      searchReset () {
        this.$refs.searchForm.resetFields();
        this.getDataList(this.page)
      },
      handleSearchShow () {
        this.searchShow = !this.searchShow;
      },
      /**
       * 刷新回调
       */
      refreshChange() {
        this.getDataList(this.page)
      }
    }
  }
</script>
